<template>
  <div>
    送货员订单
    <el-table :data="this.order" border style="width: 100%">
      <el-table-column prop="id" label="订单号" width="180"/>
      <el-table-column prop="receiverName" label="收货人" width="180"/>
      <el-table-column prop="receiverPhone" label="收货人电话" width="180"/>
      <el-table-column prop="sumPrice" label="订单总价" width="180"/>
      <el-table-column label="结账" width="180">
        <template #default="scope">
          <el-button
              size="small"
              type="primary"
              @click="compile(scope.row)">结账
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      order: {},
    }
  },
  created() {
    this.findByStatus();
  },
  methods: {
    findByStatus() {
      axios.get("/project/order/findByStatus").then(resp => {
        this.order = resp.data;
      })
    },
    compile(orderObj) {
      axios.get("/project/order/compile", {
        params: {
          orderId: orderObj.id,
        }
      }).then(resp => {
        if (resp.data == "ok") {
          this.findByStatus();
        }
      })
    },
  }
}

</script>

<style scoped>

</style>